<?php
	include_once '../classes/hocvien_bs.php';
	include_once '../classes/lophoc_bs.php';
	include_once '../classes/hopdong_bs.php';
	include_once '../classes/giaovien_bs.php';
	
	if(isset($_GET['mlh']) && trim($_GET['mlh']))
	{	
		$MaLopHoc = trim($_GET['mlh']);
		
		$LopHoc = new lophoc_bs();
		$LopHoc->SetMaLopHoc($MaLopHoc);
		$DLopHoc = $LopHoc->LayDanhSach();
		
		$HopDong = new hopdong_bs();
		$HopDong->SetMaLopHoc($MaLopHoc);
		$HopDong->SetMaVaiTro('VG01');
		$DHopDong = $HopDong->LayDanhSach();
		//Lấy họ tên GV1
		$GV1 = 'Chưa phân công';
		if($DHopDong != null)
		{
			$GiaoVien = new giaovien_bs();
			$GiaoVien->SetMaGiaoVien($DHopDong[0]['MaGiaoVien']);
			$DGiaoVien = $GiaoVien->LayDanhSach();
			$GV1 = $DGiaoVien == null ? "N/A" : $DGiaoVien[0]['HoTen'];
		}
		
		$HopDong = new hopdong_bs();
		$HopDong->SetMaLopHoc($MaLopHoc);
		$HopDong->SetMaVaiTro('VG02');
		$DHopDong = $HopDong->LayDanhSach();
		//Lấy họ tên GV1
		$GV2 = 'Không phân công';
		if($DHopDong != null)
		{
			$GiaoVien = new giaovien_bs();
			$GiaoVien->SetMaGiaoVien($DHopDong[0]['MaGiaoVien']);
			$DGiaoVien = $GiaoVien->LayDanhSach();
			$GV2 = $DGiaoVien == null ? "N/A" : $DGiaoVien[0]['HoTen'];
		}
		
		$HocVien = new hocvien_bs();
		$HocVien->SetMaLopHoc($MaLopHoc);
		$DHocVien = $HocVien->LayDanhSach();
?>
		<div class="TableList">
			<div class="Title">
				<h3 style="text-align:center; font-size:14px;">
					DANH SÁCH HỌC VIÊN LỚP <?php echo $DLopHoc[0]['MaLopHoc']; ?>
				</h3>
				<div style="float:right">
					<a id="Export" href="#"><img src="../data/export_excel.png" alt="" /></a>
				</div>
			</div>
			<div width="100%">
				<table style="border:0">
					<tr>
						<td style="border:0">Giáo viên 1:</td>
						<td style="border:0"><?php echo $GV1; ?></td>
						<td style="border:0">Giáo viên 2:</td>
						<td style="border:0"><?php echo $GV2; ?></td>
					</tr>
				</table>
			</div>
			<div width="100%">
				<table width="100%">
					<tr>
						<th class="first">STT</th>
						<th>Mã học viên</th>
						<th colspan="2">Họ tên</th>
						<th>Ngày sinh</th>
						<th>Nữ</th>
						<th>Lớp (AGU)</th>
						<th>Điện thoại</th>
					</tr>
					<?php
						for($i = 0; $i < count($DHocVien); $i++)
						{
							$tmp = TachHoTen($DHocVien[$i]['HoTen']);
							echo '<tr>';
								echo '<td align="center"><b>' . ($i + 1) . '</b></td>';
								echo '<td>' . $DHocVien[$i]['MaHocVien'] . '</td>';
								echo '<td>' . $tmp[0] . '</td>';
								echo '<td>' . $tmp[1] . '</td>';
								echo '<td>' . ConvertDate($DHocVien[$i]['NgaySinh']) . '</td>';
								echo '<td align="center">';
									echo '<input type="checkbox" disabled="true" id="c' . $i . '" class="css-checkbox" ' . ($DHocVien[$i]['GioiTinh'] == 1 ? 'checked="true"' : '') . '/>';
									echo '<label for="c' . $i . '" class="css-labelCheckbox"></label>';
								echo '</td>';
								echo '<td>' . $DHocVien[$i]['Lop'] . '</td>';
								echo '<td align="right">' . DinhDangSDT($DHocVien[$i]['DienThoai']) . '</td>';
							echo '</tr>';
						}
					?>
				</table>
			</div>
		</div>
<?php
	}
?>
<script type="text/javascript">
	$('#Export').click(function() {
		var link = "hocvien_danhsachlop_exp.php?lop=" + "<?php echo $MaLopHoc; ?>";
		location.href = link;
	});
</script>
